package org.dcarew.stripjar;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class VerboseOutputFile {

  public static List<String> parseClasses(File file) throws IOException {
    List<String> classes = new ArrayList<String>();

    BufferedReader reader = new BufferedReader(new FileReader(file));

    String line = reader.readLine();

    // [Loaded java.lang.Object from /System/Librar ... tents/Classes/classes.jar]
    while (line != null) {
      if (line.startsWith("[Loaded ") && line.endsWith("]")) {
        String[] strs = line.split(" ");

        if (strs.length >= 2) {
          String className = strs[1];

          if (!className.startsWith("java.")) {
            classes.add(Utils.classNameToPathName(className));
          }
        }
      }

      line = reader.readLine();
    }

    reader.close();

    return classes;
  }

}
